<?php
include_once("ClsSebent/config.php");
$rem_img=$_REQUEST['rem_img'];

if($rem_img=="y" && $_SESSION['SITE_ID'] != ""){

		$sql="UPDATE site_home SET  page_bg_image='' WHERE id=$_SESSION['SITE_ID']";
		//echo $sql;
		mysql_query($sql);		
		header("Location: skin.php?site_id=".$_SESSION['SITE_ID']);
	}

//******************SKIN RESET***********************
if("$action"=="resetskin" && $_SESSION['SITE_ID'] != "")
	{
		$sql="SELECT * FROM site_home WHERE id='101'";

		$result = mysql_query($sql);
		$num=1;
		if($main_data=mysql_fetch_array($result))
		{
		$sql="UPDATE `site_home` SET `page_bg_image`='" . mysql_escape_string($main_data["page_bg_image"]) . "', `page_bg_image_alt`='" . mysql_escape_string($main_data["page_bg_image_alt"]) . "' , `page_bg_color`='" . $main_data["page_bg_color"] . "' , `bdr_color1`='".$main_data['bdr_color1']."', `bdr_color2`='".$main_data['bdr_color2']."', `bdr_color3`='".$main_data['bdr_color3']."', `page_text_color`='" . $main_data["page_text_color"] . "', page_tdtext_color='".$main_data['page_tdtext_color']."', `page_title_color`='" . $main_data["page_title_color"] . "' , `page_link_text_color`='" . $main_data["page_link_text_color"] . "' , `page_link_visited_color`='" . $main_data["page_link_visited_color"] . "' , `page_link_rollover_color`='" . $main_data["page_link_rollover_color"] . "' WHERE id=$_SESSION['SITE_ID']";
			//echo $sql;
			mysql_query($sql);			
			/*
			$c_n_i=$main_data["company_name_img"];
			if("$c_n_i" != "") copy("./photos/${site_id}_" . $c_n_i,"./photos/${new_site_id}_" . $c_n_i);

			$logo=$main_data["logo"];
			if("$logo" != "") copy("./logos/${site_id}_" . $logo,"./logos/${new_site_id}_" . $logo);
			*/
			$b_bg_i=$main_data["page_bg_image"];
			if("$b_bg_i" !="") copy("./photos/header/101_" . $b_bg_i,"./photos/header/${site_id}_" . $b_bg_i);

		}
	}
//******************SKIN RESET***********************

include_once("king_head.php");
	//if("$action"=="Color Pellette")	$exec=shell_exec("ColorPellette.exe");
?>
<script type="text/javascript">
function confirmation()
{
var c=confirm("The Changes will not be reverted back. Although, you can set them again manually. Are you sure to Save Changes??");
if(c)
return true;
else
return false;
}
</script>
<?php
	//include_once("ClsSebent/config.php");

	if("$action"=="Save" && $_SESSION['SITE_ID'] != "")
	{
		$page_bg_image_alt=str_replace("'","''",$page_bg_image_alt);
		$page_bg_image_alt=str_replace('"','""',$page_bg_image_alt);
		$page_bg_image_alt=str_replace('\\','',$page_bg_image_alt);
		$page_bg_color=str_replace("#","",$page_bg_color);
		$bdr_color1=str_replace("#","",$bdr_color1);
		$bdr_color2=str_replace("#","",$bdr_color2);
		$bdr_color3=str_replace("#","",$bdr_color3);
		$page_text_color=str_replace("#","",$page_text_color);
		$page_table_text_color=str_replace("#","",$page_table_text_color);
		$page_title_color=str_replace("#","",$page_title_color);
		$page_link_text_color=str_replace("#","",$page_link_text_color);
		$page_link_visited_color=str_replace("#","",$page_link_visited_color);
		$page_link_rollover_color=str_replace("#","",$page_link_rollover_color);

		$sql="UPDATE site_home SET  page_bg_image_alt='$page_bg_image_alt', page_bg_color='$page_bg_color', bdr_color1='$bdr_color1', bdr_color2='$bdr_color2', bdr_color3='$bdr_color3', page_text_color='$page_text_color', page_tdtext_color='$page_table_text_color', page_link_text_color='$page_link_text_color', page_link_visited_color='$page_link_visited_color', page_link_rollover_color='$page_link_rollover_color', page_title_color='$page_title_color'";

	    if (isset($page_bg_image) && $page_bg_image != "") 
		{
			if(!copy($page_bg_image,"./photos/header/${site_id}_" . $page_bg_image_name))
			{ echo "coping error!"; exit;}
			$sql=$sql . ", page_bg_image='$page_bg_image_name'";
		}

		$sql=$sql . " WHERE id=$_SESSION['SITE_ID']";
		//echo $sql;
		mysql_query($sql);
	}
	
	$sql="SELECT * FROM site_home WHERE id=$_SESSION['SITE_ID']";

	$result = mysql_query($sql);
	if($row=mysql_fetch_array($result))
	{
		$company_name=$row["company_name"];
		$page_bg_image=$row["page_bg_image"];
		$page_bg_image_alt=$row["page_bg_image_alt"];
		$page_bg_color=$row["page_bg_color"];
		$bdr_color1=$row["bdr_color1"];
		$bdr_color2=$row["bdr_color2"];
		$bdr_color3=$row["bdr_color3"];
		$page_table_text_color=$row["page_tdtext_color"];
		$page_text_color=$row["page_text_color"];
		$page_title_color=$row["page_title_color"];
		$page_link_text_color=$row["page_link_text_color"];
		$page_link_visited_color=$row["page_link_visited_color"];
		$page_link_rollover_color=$row["page_link_rollover_color"];
		$menu_link_text_color=$row["menu_link_text_color"];
		$page_bg_image_alt=str_replace("''","'",$page_bg_image_alt);
		$page_bg_image_alt=str_replace('""','"',$page_bg_image_alt);
	}
?>

<CENTER>
<H2> Skin Control Panel<BR>(<?php echo $company_name;?>)</H2>
<form enctype="multipart/form-data"  method="post" name="frm" onsubmit="javascript: return confirmation();">
<?php if($_SESSION['SITE_ID']!=101){?><a href="confirm.php?action=resetskin&site_id=<?php echo $_SESSION['SITE_ID']; ?>">Reset the website skin</a><?php }?>
  <input type=hidden name=site_id value="<?php echo $_SESSION['SITE_ID']; ?>" />
  <TABLE>
<tr><td>Page-header background image <br> (size ~ 150x500px)</td><td><input type=file name=page_bg_image value="<?php echo $page_bg_image; ?>" size=20>&nbsp; 
	<?php if("$page_bg_image" !=""){ ?><a href="photos/header/<?php echo $_SESSION['SITE_ID'] . "_" . $page_bg_image; ?>" target="_n1">View current bg-image</a>&nbsp;&nbsp;<a href='skin.php?site_id=<?php echo $_SESSION['SITE_ID']; ?>&rem_img=y'>Remove Image</a><?php } else echo "(No existing image)"; ?></td></tr>
<tr><td>Page-header background image alt</td><td>
	<input name=page_bg_image_alt size=20 Value="<?php echo $page_bg_image_alt;?>"> 
</td></tr>
<tr><td>Page background color</td>
<td><input type=text name=page_bg_color value="<?php echo $page_bg_color;?>" size="20"><?php pk_color('page_bg_color',1);?></td></tr>
<tr>
  <td>Page border color(main) </td>
  <td><input type=text name=bdr_color1 value="<?php echo $bdr_color1;?>" size="20" /><?php pk_color('bdr_color1',2);?></td>
</tr>
<tr>
  <td>Page border color(header) </td>
  <td><input type=text name=bdr_color2 value="<?php echo $bdr_color2;?>" size="20" /><?php pk_color('bdr_color2',3);?></td>
</tr>
<tr>
  <td>Page border color(navigation bar) </td>
  <td><input type=text name=bdr_color3 value="<?php echo $bdr_color3;?>" size="20" /><?php pk_color('bdr_color3',4);?></td>
</tr>
<tr><td>Page text color  </td><td>
<input type=text name=page_text_color value="<?php echo $page_text_color;?>" size="20"><?php pk_color('page_text_color',5);?></td></tr>
<tr><td>Page table text color  </td><td>
<input type=text name=page_table_text_color value="<?php echo $page_table_text_color;?>" size="20"><?php pk_color('page_table_text_color',6);?></td></tr>
<tr><td>Page title color  </td><td>
	<input type=text name=page_title_color value="<?php echo $page_title_color;?>" size="20"><?php pk_color('page_title_color',7);?></td></tr>
<tr><td>Link text color </td><td>
	<input type=text name=page_link_text_color value="<?php echo $page_link_text_color;?>" size="20"><?php pk_color('page_link_text_color',8);?></td></tr>
<tr><td>Link visited color </td><td>
	<input type=text name=page_link_visited_color value="<?php echo $page_link_visited_color;?>" size="20"><?php pk_color('page_link_visited_color',9);?></td></tr>
<tr><td>Link rollover color </td><td>
	<input type=text name=page_link_rollover_color value="<?php echo $page_link_rollover_color;?>" size="20"><?php pk_color('page_link_rollover_color',10);?></td></tr>
<tr><td colspan=2 align=center><input type=submit name=action value=Save> <!--<input type=submit name=action value='Color Pellette'>--></TD>
</TR>
</TABLE>
</form>
</CENTER>
<?php
	include_once("king_foot.php");
?>
